# -*- coding: utf-8 -*-
import functools


class Vision():
    def __init__(self,mem,red,video):
        self.mem = mem
        self.red=red

        self.mem.insertData("redBallDetected",[[1,1],[1,1,1,1],[1,1,1,1,1,1],[1,1,1,1,1,1],1])
        print self.mem.getData("redBallDetected")
        self.red.subscribe("RedBallDetection", 1000, 0.7)
        self.redball=self.mem.subscriber("redBallDetected")
        # self.subscriber=video.subscribeCamera("RedBallDetection", 1, 2, 13, 60)

        self.con_redball = self.redball.signal.connect(functools.partial(self.Redball_Det, "redBallDetected"))
        self.stop_flag=False
    def Redball_Det(self, event, value):
        print event, value
        print value[1][1], value[4]
        if value[1][1]>0.27 and value[4] ==1:
        #检测到红球，停止位置真
            self.stop_flag=True
            print "检测到红球。"
